<template>
  <div class="qrcode-container layout-pd">
    <!-- 支付信息 -->
    <el-col :span="24">
      <el-card shadow="hover" header="支付信息">
        <div style="margin:0px auto;max-width: 300px">
          <div class="pay-info">
            <div class="pay-first">支付单号:</div>
            <div class="pay-second">23045345213354543534</div>
          </div>
          <div class="pay-info">
            <div class="pay-first">金额:</div>
            <div class="pay-second">2334543</div>
          </div>

          <div class="qrcode-img-warp">
            <div class="mb30 mt30 qrcode-img">
              <div class="qrcode" ref="qrcodeRef"></div>
            </div>
          </div>
        </div>
      </el-card>
    </el-col>


  </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue';
import QRCode from 'qrcodejs2-fixes';
import {orderApi} from "/@/api/order";
import {useRouter, useRoute} from 'vue-router';

const route = useRoute();
const router = useRouter(); // 获取路由实例
// 定义变量内容
const qrcodeRef = ref();

// 初始化生成二维码
const initQrcode = (content) => {
  console.log(content,333)
  new QRCode(qrcodeRef.value, {
    text: content,
    width: 300,
    height: 300,
    colorDark: '#000000',
    colorLight: '#ffffff',
  });
};
// 页面加载时
onMounted(() => {
  // let str ='weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00'
  // initQrcode(str);
  orderPay();
});
const orderPay = async () => {
  const res = await orderApi().toPay({order_sn: route.query.sn})
  if (res.code != 0) {
    return;
  }
  let qrcode=res.data.code_url;
  initQrcode(qrcode);
}
</script>

<style scoped lang="scss">
@import '../../../theme/mixins/index';

.qrcode-container {
  .qrcode-img-warp {
    text-align: center;

    .qrcode-img {
      display: flex;
      width: 100%;
      //height: 125px;

      .qrcode {
        margin: auto;
        //width: 125px;
        //height: 125px;
      }
    }
  }
}

.pay-info {
  display: flex;
  text-align: left;
  margin-top: 10px;
}

.pay-first {
  width: 80px;
  text-align: left;
  //font-weight: 600;
  font-size: 14px;
  height: 24px;
  line-height: 24px;
  color: rgba(0, 0, 0, .85)
}

.pay-second {
  //font-weight: 600;
  font-size: 14px;
  height: 24px;
  line-height: 24px;
  margin-left: 20px;
  color: rgba(0, 0, 0, .85);
}
</style>
